<?php
namespace addons\mall\controller;

use app\admin\controller\Addon;
use think\facade\Request;

/**
 * @ControllerAnnotation(title="mall_spec")
 * NotParse
 */
class Spec extends Addon
{
    public function edit()
    {
        $id  = Request::param('id');
        $row = $this->model->find($id);
        empty($row) && $this->error('数据不存在');
        if ($this->request->isAjax()) {
            $post = $this->request->post();
            $rule = [];
            $this->validate($post, $rule);
            try {
                $save = $row->save($post);
            } catch (\Exception $e) {
                $this->error('保存失败');
            }
            $save ? $this->success('保存成功') : $this->error('保存失败');
        }
        $this->assign('row', $row);
        return $this->fetch();
    }
}
